home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#19 (Apr 87)
/
zbasic scroll
/
INDEXSCROLL.BAS
next >
Wrap
BASIC Source File
|
1987-02-19
|
4KB
|
144 lines
REM *************** Text Window Scroll Bar(s) Example ********************
REM *** ZBasic 3.05 or Greater (public domain) 1/87 A.G ZEDCOR, INC. ***
REM *** with modifications & explainations 2/87 by D. Kelly MacTutor™ ***
REM **********************************************************************
WINDOW OFF
COORDINATE WINDOW
DIM ST(30,1)
CLEAR 11000
TL = 0
WIDTH -2
False = 0 : True = NOT False
X=MEM(-1) :REM *** Disable Line Wrap ***
WINDOW 1,"INDEX / SCROLL Demo",(50,50)-(450,255),9 : REM ** Initial Window Size **
TEXT 4,9
MENU 1,0,1,"File"
MENU 1,1,1,"Quit"
MENU 2,0,1,"Scroll Type"
MENU 2,1,1,"Normal Scroll"
MENU 2,2,1,"Soft Scroll"
MENU 3,0,1,"INDEX Demo"
MENU 3,1,1,"Add Record/A"
MENU 3,2,1,"Insert Record/I"
MENU 3,3,1,"Edit Record/E"
MENU 3,4,1,"Find Record/F"
MENU 3,5,1,"Delete Record/D"
DIM Ascent,Descent,WidMax,Leading
CALL GETFONTINFO(Ascent)
Height=Ascent+Descent+Leading :REM * Font Size *
OV=False
OH=True
Softscroll=False : REM **** Softscroll = Soft-Scroll Flag ****
SCROLL BUTTON 1,OV,OV,TL-1,TL/10,,1
SCROLL BUTTON 2,OH,OH,255,10,,2
ON DIALOG GOSUB "Dialog"
ON MENU GOSUB "MenuEvent"
DIALOG ON
MENU ON
BREAK ON : REM **> Var 'Softscroll' 0=Normal Scroll 1=Soft Scroll **
"Loop" : GOTO "Loop" : REM *** Main Event Trapping Loop ***
DIALOG OFF: BREAK OFF :MENU OFF: REM *** Turn OFF dialogs for rest of PGM ***
"MenuEvent"
Menunumber = MENU(0)
Menuitem = MENU(1)
ON Menunumber GOSUB "File","Scroll","Index"
MENU
RETURN
"File"
IF Menunumber = 1 THEN STOP
RETURN
"Scroll"
IF Menuitem = 1 THEN Softscroll = 0 ELSE Softscroll = 1
RETURN
"Index"
ON Menuitem GOSUB "Add","Insert","Change","Find","Delete"
RETURN
"Dialog" : D=DIALOG(0) : REM **** Dialog Events come here.. ****
ON D GOTO "Button","X","Active","GoAway","Update","X","X","Zoom","Zoom"
"Active"
WINDOW #DIALOG(D)
RETURN : REM ** Activate this Window **
"Button"
IF DIALOG(D)=1 THEN Buttonvalue=BUTTON(1) ELSE "Side"
X=OV-Buttonvalue
IF ABS(X) > SL THEN OV=Buttonvalue : CLS : GOTO "Update"
IF X>0 THEN DV=Height :DL=-1 :Leading=0 :P=Ascent ELSE DV=-Height :DL=+1 :Leading=SL+1 :P=(SL-1)*Height+Ascent
WHILE OV<>Buttonvalue
IF Softscroll THEN DV=SGN(DV) : II=1 ELSE II=Height
FOR II=II TO Height : REM **** If THIS LINE if Soft-Scroll Not used *****
SCROLL (0,0)-(W6,W7),,DV : REM ***** SCROLL 1 line or 1 Pixel *****
PRINT %(-BUTTON(2)*WidMax,P+(DV*(II-Height)));INDEX$(OV-1+Leading);
NEXT
OV=OV+DL : REM **** Remove NEXT if soft-scroll not used ***
WEND : RETURN
"Zoom"
CLS : RETURN : REM ***** ERASE IF ZOOM-IN OR ZOOM OUT *****
"Side"
SCROLL(0,0)-(W6,W7),(OH-BUTTON(2))*WidMax,0:OH=BUTTON(2)
"Update"
W6=WINDOW(6)-1 : W7=WINDOW(7)-1 : SL=W7/Height
FOR II= OV TO OV+SL-1 : REM ******* Re-Draw Full Screen *******
PRINT %(-BUTTON(2)*WidMax,(II-OV)*Height+Ascent);INDEX$(II);
NEXT
COLOR 0 :BOX FILL 0,SL*Height TO W6,W7 :COLOR -1 :REM *Erase Bottom*
"X"
RETURN : REM **** Just RETURN routine ****
"GoAway"
WINDOW CLOSE DIALOG(4):RETURN
"Insert"
WINDOW 2,"Insert",(100,100)-(400,200),-263
TEXT 2,0 : LOCATE 1,2
INPUT "Insert record before #:";N
IF N<0 THEN N=0
IF N>TL THEN N=TL
INPUT "Insert record: ";W$
INDEX$I (N) = W$
TL = TL + 1
WINDOW CLOSE 2
WINDOW 1
SCROLL BUTTON 1,OV,OV,TL-1,TL/10,,1
CLS:GOSUB "Update"
RETURN
"Add"
WINDOW 2,"Insert",(100,100)-(400,200),-263
TEXT 2,0 : LOCATE 1,2
INPUT "Add record: ";W$
INDEX$ (TL) = W$
TL = TL + 1
WINDOW CLOSE 2
WINDOW 1
SCROLL BUTTON 1,OV,OV,TL-1,TL/10,,1
RETURN
"Delete"
WINDOW 2,"Delete",(100,100)-(400,200),-263
TEXT 2,0 : LOCATE 1,2
INPUT "Record number to delete: (<0 to abort)";N
IF N>=0 THEN INDEX$D(N) : TL = TL - 1
WINDOW CLOSE 2
SCROLL BUTTON 1,OV,OV,TL-1,TL/10,,1
WINDOW 1
CLS:GOSUB "Update"
RETURN
"Change"
WINDOW 2,"Change",(100,100)-(400,200),-263
TEXT 2,0 : LOCATE 1,2
INPUT "Record number to Change: (<0 to abort)";N
PRINT "Current record is ";INDEX$(N)
INPUT "Change record to:";W$
IF W$ = "" THEN W$ = INDEX$(N)
INDEX$(N) = W$
WINDOW CLOSE 2
WINDOW 1
CLS:GOSUB "Update"
RETURN
"Find"
WINDOW 2,"Find",(100,100)-(400,200),-263
TEXT 2,0 : LOCATE 1,2
INPUT "Record string to Find:";W$
OV=INDEXF(W$)
WINDOW CLOSE 2
WINDOW 1
SCROLL BUTTON 1,OV,OV,TL-1,TL/10,,1
CLS:GOSUB "Update"
RETURN